package com.isdepci.project.carbon.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.carbon.domain.ProductCarbonStage;
import com.isdepci.project.carbon.service.IProductCarbonStageService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 产品碳足迹-产品阶段Controller
 *
 * @author isdepci
 * @date 2024-11-11
 */
@RestController
@RequestMapping("/carbon/productCarbonStage")
public class ProductCarbonStageController extends BaseController
{
    @Autowired
    private IProductCarbonStageService productCarbonStageService;

    /**
     * 查询产品碳足迹-产品阶段列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:productCarbonStage:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductCarbonStage productCarbonStage)
    {
        startPage();
        List<ProductCarbonStage> list = productCarbonStageService.selectProductCarbonStageList(productCarbonStage);
        return getDataTable(list);
    }

    /**
     * 导出产品碳足迹-产品阶段列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:productCarbonStage:export')")
    @Log(title = "产品碳足迹-产品阶段", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProductCarbonStage productCarbonStage)
    {
        List<ProductCarbonStage> list = productCarbonStageService.selectProductCarbonStageList(productCarbonStage);
        ExcelUtil<ProductCarbonStage> util = new ExcelUtil<ProductCarbonStage>(ProductCarbonStage.class);
        return util.exportExcel(list, "productCarbonStage");
    }

    /**
     * 获取产品碳足迹-产品阶段详细信息
     */
    @PreAuthorize("@ss.hasPermi('carbon:productCarbonStage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(productCarbonStageService.selectProductCarbonStageById(id));
    }

    /**
     * 新增产品碳足迹-产品阶段
     */
    @PreAuthorize("@ss.hasPermi('carbon:productCarbonStage:add')")
    @Log(title = "产品碳足迹-产品阶段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductCarbonStage productCarbonStage)
    {
        return toAjax(productCarbonStageService.insertProductCarbonStage(productCarbonStage));
    }

    /**
     * 修改产品碳足迹-产品阶段
     */
    @PreAuthorize("@ss.hasPermi('carbon:productCarbonStage:edit')")
    @Log(title = "产品碳足迹-产品阶段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductCarbonStage productCarbonStage)
    {
        return toAjax(productCarbonStageService.updateProductCarbonStage(productCarbonStage));
    }

    /**
     * 删除产品碳足迹-产品阶段
     */
    @PreAuthorize("@ss.hasPermi('carbon:productCarbonStage:remove')")
    @Log(title = "产品碳足迹-产品阶段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productCarbonStageService.deleteProductCarbonStageByIds(ids));
    }
}
